<?php
include('../Class/SanPham_Class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Sửa thông tin sản phẩm </title>
<head>
<meta content="en-us" http-equiv="Content-Language" />
<script type="text/javascript" src="js/common.js"></script>
<style type="text/css">
.auto-style1 {
	font-weight: bold;
}
</style>
</head>
<?php
if(isset($_GET['id']))
{
$id=$_GET['id'];
$sanpham=new SanPham();
$sp=$sanpham->GetbyID($id);
$a=@mysql_fetch_assoc($sp);
}
?>
<body>
<form name="formParent" action="Update_SanPham.php?id=<?php echo $id; ?>" method="post">
<div>Sửa thông tin Sản Phẩm</div>
	<table style="width: 100%">
				<tr>
			<td style="width: 104px; height: 27px;">Tên Sản Phẩm</td>
			<td style="height: 27px"><input name="tensp" style="width: 191px" type="text" value="<?php echo $a['TenSP'];?>" /></td>
		</tr>
		<tr>
			<td style="width: 104px; height: 30px">Hình ảnh</td>
			<td style="height: 30px">
			<input type="text" name="imageDefault" tabindex="2" title="Image Default" size="35" value="<?php echo $a['HinhAnh'];?>" />
    		<a href="javascript:void(0)" onclick="openURL('upload_form.php');">Choose file</a></td>
		</tr>
		<tr>
			<td style="width: 104px">Giá</td>
			<td><input name="gia" style="width: 187px" type="text" value="<?php echo $a['Gia'];?>" /></td>
		</tr>
		<tr>
			<td style="width: 104px">Mô tả</td>
			<td><textarea name="textareamota" rows="2" style="width: 301px"><?php echo $a['MoTa'];?></textarea></td>
		</tr>
		<tr>
			<td style="width: 104px; height: 28px">Mã NSX</td>
			<td style="height: 28px">
			<input name="mansx" style="width: 101px" type="text" value="<?php echo $a['MaNSX'];?>" /></td>
		</tr>
		<tr>
			<td style="width: 104px">&nbsp;</td>
			<td><input name="Submit" type="submit" value="Sửa" /></td>
		</tr>
	</table>
</form>
<?php
if($_GET['id'])
{
$id=$_GET['id'];
}
if(isset($_POST['tensp'])&&isset($_POST['imageDefault'])&&isset($_POST['gia'])&&isset($_POST['textareamota'])&&isset($_POST['mansx']))
{
$TenSP=$_POST['tensp'];
$HinhAnh=$_POST['imageDefault'];
$Gia=$_POST['gia'];
$MoTa=$_POST['textareamota'];
$MaNSX=$_POST['mansx'];
$sanpham=new SanPham();
if($sanpham->Update_SanPham($id,$TenSP,$HinhAnh,$Gia,$MoTa,$MaNSX)<0)
{
echo "Sửa thất bạii!!".@mysql_error();
}
else
{
echo "Sửa thành công!!";
header('location: Delete_SanPham.php');
}
}
?>

</body>

</html>
